package cool.gaogao.aop.user;

/**
 * @author 高山青
 * @Date 2021/12/31  -   10:18
 */

import jdk.internal.org.objectweb.asm.tree.analysis.Value;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 被增强类1
 */
@Component
@Aspect
@Order(1)//增强优先级
public class UserProxy {
	//相同切入点的提取
	@Pointcut(value="execution(* cool.gaogao.aop.user.User.add(..))")
	public void pointcut(){

	}

	@Before(value="pointcut()")
	public void before(){
		System.out.println("前置通知。。。");
	}
	@After(value="pointcut()")
	public void after(){
		System.out.println("最终通知。。。");
	}
	@AfterReturning(value="pointcut()")
	public void afterReturning(){
		System.out.println("后置通知有返回值。。。");
	}
	@AfterThrowing(value="pointcut()")
	public void afterThrowing(){
		System.out.println("异常通知。。。");
	}
	@Around(value="pointcut()")//环绕通知，方法前后都执行。
	public void around(ProceedingJoinPoint proceedingJoinPoint){
		System.out.println("方法执行前。。。");
		try {
			proceedingJoinPoint.proceed();
		} catch (Throwable throwable) {
			throwable.printStackTrace();
		}
		System.out.println("方法执行后。。。");

	}
}
